package com.wwz.dao;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface ProductDao {

    @Insert("insert into tb_product(name) values(#{name})")
    int insert(@Param("name")String name);

    @Update("update tb_product a set num = num-#{num} where id=#{id} and num-#{num}>=0")
    int update(@Param("num")String num,@Param("id") long id);

    @Update("update tb_product set num = num+#{num} where id=#{id}")
    int updateNum(@Param("num")String num,@Param("id") long id);
}
